<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                xmlns:ds="http://deltaset.org/deltaset-faces"
                xmlns:mi="http://java.sun.com/jsf/composite/deltaset.meta/internal"
                xmlns:composite="http://java.sun.com/jsf/composite"> 

    <ds:fieldset width="550px">
        <h:messages styleClass="ui-state-highlight ui-corner-all"/>
        <h:panelGroup rendered="#{not empty meta.executorResult}" layout="block" styleClass="ui-widget-content">        
            <c:if test="#{meta.executorResult.isCollection()}">
                <ui:include src="fields/list-collection.xhtml">
                    <ui:param name="value" value="#{meta.executorResult.value}"/>
                    <ui:param name="meta" value="#{meta}"/>                    
                </ui:include>
            </c:if>
            <c:if test="#{meta.executorResult.isEntity()}">   
                <ds:fieldset width="95%">
                    <h3>#{meta.labelClass(meta.executorResult.resultClass)}</h3>
                    <mi:detail-fields fields="#{meta.executorResult.detailFields}" 
                                      model="#{meta.executorResult.value}" 
                                      meta="#{meta}" 
                                      owner="#{meta.executorResult.resultClass}"/>
                </ds:fieldset>
            </c:if>
            <c:if test="#{meta.executorResult.isDate()}">
                <ui:include src="fields/list-date.xhtml">
                    <ui:param name="value" value="#{meta.executorResult.value}"/>
                </ui:include>
            </c:if>
            <c:if test="#{meta.executorResult.isSimple()}">
                <ui:include src="fields/list-string.xhtml">
                    <ui:param name="value" value="#{meta.executorResult.value}"/>
                </ui:include>
            </c:if>        
        </h:panelGroup>

        <h:panelGroup rendered="#{not empty meta.executor}" layout="block"> 
            <c:set var="action" value="#{meta.executor.metaAction}"/>

            <h3>#{meta.labelAction(action)}</h3>
            <mi:form-fields fields="#{action.parameterMetaFields}" model="#{meta.executor.parameterValue}" meta="#{meta}" owner="#{action}" formId="#{formId}"/>

            <div style="width:100%;clear:both;padding-top:10px;display: block;text-align: right">
                <h:commandButton  rendered="#{not action.isReturningEntity}"
                                  value="'#{meta.labelAction(action)}'"                                      
                                  action="#{meta.executeAction}"
                                  styleClass="ds-button">
                    <f:ajax execute="@form"  render="@form"/>
                </h:commandButton>
                <h:commandButton  rendered="#{action.isReturningEntity}"
                                  value="'#{meta.labelAction(action)}'"                                      
                                  action="#{meta.executeAction}"
                                  styleClass="ds-button">
                    <f:ajax execute="@form" onevent="#{switchExecuteForEdit}" render="@form #{editPanelFormId}"/>
                </h:commandButton>
                <h:commandButton  value="cancel"                                      
                                  action="#{meta.cancelExecutor}"
                                  styleClass="ds-button">
                    <f:ajax execute="@form" onevent="#{executePanelClose}" render="@form"/>
                </h:commandButton>
            </div>
        </h:panelGroup>  
    </ds:fieldset>
</ui:composition>
